<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/4/13 0013 19:29
 */


// 这是所有一个模板的所有页面，读取某一个文件夹里面所有的文件，显示出来，可以点击前往编辑



require_once 'file.php';

// 获得整个结构目录
$path = $_GET['site'];
$path2 = iconv("utf-8","gb2312",$path);

analysisPath($allFile, $path2, function(DirectoryIterator $object)use ($path2){
    $getpath=iconv("utf-8","gb2312",str_replace($path2, '', $object->getPath() . '/') . $object->getFilename());
    return $getpath;

});

// 用下面这个形式展示
// http://down.admin5.com/demo/code_pop/18/1417/

function sub($html){
    if(is_string($html)){
        return substr($html, strrpos($html, '.') + 1);
    }
   return '';
}
?>

<html>
<head>
    <link id="bootstrap_221" rel="stylesheet" type="text/css" class="library" href="http://sandbox.runjs.cn/js/sandbox/bootstrap-2.2.1/css/bootstrap.min.css">
    <script id="jquery_172" type="text/javascript" class="library" src="http://sandbox.runjs.cn/js/sandbox/jquery/jquery-1.7.2.min.js"></script>
    <script id="bootstrap_221" type="text/javascript" class="library" src="http://sandbox.runjs.cn/js/sandbox/bootstrap-2.2.1/js/bootstrap.min.js"></script>
    <link rel="stylesheet" type="text/css" href="my.css">
    <script type="text/javascript" src="my.js"></script>
</head>
<body>
<div class="tree well">
    <ul>
        <li>
            <span><i class="icon-folder-open"></i>站点根目录</span> <a href=""><?= $_GET['site']?></a>
            <ul>
                <?php foreach ($allFile as $html=>$file){?>
                <li>
                    <span><i class="icon-minus-sign"></i> Child</span>
                    <?php if(sub($html)=='html' || sub($html)=='htm'){?>
                        <a href="<?= $_GET['site']?>/<?= $html?>"><?= $html?></a><a href="template-edit.php?content=<?= $path?><?= $html?>">编辑</a>
                    <?php }else{?>
                        <?= $html?>
                    <?php }?>
                    <?php if(is_array($file)){
                        foreach ($file as $item){?>
                    <ul>
                        <li>
                            <span><i class="icon-leaf"></i> Grand Child</span>
                            <?php if(sub($item)=='jpg' || sub($item)=='png'){?>
                            <a href="<?= $_GET['site']?>/<?= $item?>"><?= $item?></a>
                            <?php }else{?>
                              <?php if(is_array($item)){
                                    foreach ($item as $item){?>
                                        <ul>
                                            <li>
                                                <span><i class="icon-leaf"></i> Grand Child</span>
                                                <?php if(sub($item)=='jpg' || sub($item)=='png'){?>
                                                    <a href="<?= $_GET['site']?>/<?= $item?>"><?= $item?></a>
                                                <?php }else{?>
                                                    <?= $item?>
                                                    <?php if(sub($item)=='js' || sub($item)=='css'){?>
                                                        <a href="template-edit-text.php?content=<?= $path?><?= $item?>"><?= $item?>编辑</a>
                                                    <?php }?>
                                                <?php }?>
                                            </li>
                                        </ul>
                                    <?php }}?>
                                <?php if(sub($item)=='js' || sub($item)=='css'){?>
                                    <a href="template-edit-text.php?content=<?= $path?><?= $item?>"><?= $item?>编辑</a>
                                <?php }?>
                            <?php }?>
                        </li>
                    </ul>
                    <?php }}?>
                </li>
                <?php }?>
<!--                <li>-->
<!--                    <span><i class="icon-minus-sign"></i> Child</span> <a href="">Goes somewhere</a>-->
<!--                    <ul>-->
<!--                        <li>-->
<!--                            <span><i class="icon-leaf"></i> Grand Child</span> <a href="">Goes somewhere</a>-->
<!--                        </li>-->
<!--                        <li>-->
<!--                            <span><i class="icon-minus-sign"></i> Grand Child</span> <a href="">Goes somewhere</a>-->
<!--                            <ul>-->
<!--                                <li>-->
<!--                                    <span><i class="icon-minus-sign"></i> Great Grand Child</span> <a href="">Goes somewhere</a>-->
<!--                                    <ul>-->
<!--                                        <li>-->
<!--                                            <span><i class="icon-leaf"></i> Great great Grand Child</span> <a href="">Goes somewhere</a>-->
<!--                                        </li>-->
<!--                                        <li>-->
<!--                                            <span><i class="icon-leaf"></i> Great great Grand Child</span> <a href="">Goes somewhere</a>-->
<!--                                        </li>-->
<!--                                    </ul>-->
<!--                                </li>-->
<!--                                <li>-->
<!--                                    <span><i class="icon-leaf"></i> Great Grand Child</span> <a href="">Goes somewhere</a>-->
<!--                                </li>-->
<!--                                <li>-->
<!--                                    <span><i class="icon-leaf"></i> Great Grand Child</span> <a href="">Goes somewhere</a>-->
<!--                                </li>-->
<!--                            </ul>-->
<!--                        </li>-->
<!--                        <li>-->
<!--                            <span><i class="icon-leaf"></i> Grand Child</span> <a href="">Goes somewhere</a>-->
<!--                        </li>-->
<!--                    </ul>-->
<!--                </li>-->
            </ul>
        </li>
    </ul>
</div>
</body>
</html>
